<?php require_once('../../Connections/agriculture.php'); ?>
<?php


//1为供应 ,2为需求
$messageType;

if($_GET['type']==2){
$messageType=2;
}else{
$messageType=1;
}

$currentPage = $_SERVER["PHP_SELF"];

$maxRows_GoodsInfoRecordset1 = 5;
$pageNum_GoodsInfoRecordset1 = 0;
if (isset($_GET['pageNum_GoodsInfoRecordset1'])) {
  $pageNum_GoodsInfoRecordset1 = $_GET['pageNum_GoodsInfoRecordset1'];
}
$startRow_GoodsInfoRecordset1 = $pageNum_GoodsInfoRecordset1 * $maxRows_GoodsInfoRecordset1;

mysql_select_db($database_agriculture, $agriculture);
$query_GoodsInfoRecordset1 = "SELECT * FROM message WHERE message_classid =".$messageType." and message_visible='显示' ";
$query_limit_GoodsInfoRecordset1 = sprintf("%s LIMIT %d, %d", $query_GoodsInfoRecordset1, $startRow_GoodsInfoRecordset1, $maxRows_GoodsInfoRecordset1);
$GoodsInfoRecordset1 = mysql_query($query_limit_GoodsInfoRecordset1, $agriculture) or die(mysql_error());
$row_GoodsInfoRecordset1 = mysql_fetch_assoc($GoodsInfoRecordset1);

if (isset($_GET['totalRows_GoodsInfoRecordset1'])) {
  $totalRows_GoodsInfoRecordset1 = $_GET['totalRows_GoodsInfoRecordset1'];
} else {
  $all_GoodsInfoRecordset1 = mysql_query($query_GoodsInfoRecordset1);
  $totalRows_GoodsInfoRecordset1 = mysql_num_rows($all_GoodsInfoRecordset1);
}
$totalPages_GoodsInfoRecordset1 = ceil($totalRows_GoodsInfoRecordset1/$maxRows_GoodsInfoRecordset1)-1;

$queryString_GoodsInfoRecordset1 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_GoodsInfoRecordset1") == false && 
        stristr($param, "totalRows_GoodsInfoRecordset1") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_GoodsInfoRecordset1 = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_GoodsInfoRecordset1 = sprintf("&totalRows_GoodsInfoRecordset1=%d%s", $totalRows_GoodsInfoRecordset1, $queryString_GoodsInfoRecordset1);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>海南热带设施农业网站供求信息平台</title>
</head>

<body>
<p>
<?php
$user=$_SESSION['poster'];

//如果未登陆,则显示登陆和注册,否则显示退出按钮
if($user==""){
echo '<a href="login.php">登陆</a> <a href="reg.php">注册</a>';
}else{
echo $user.'<a href="out.php">退出</a>&nbsp;&nbsp;';
echo '<a href="post.php">发布信息</a>';
}
?>
</p>



<p>
<?php
//1为供应 ,2为需求

if($messageType==1){
echo '<a href="info.php?type=2">查看需求信息</a>';
$messageType=2;
}
else{
echo '<a href="info.php?type=1">查看供应信息</a>';
$messageType=1;
}
?>
</p>


<?php do { ?>
  <p>&nbsp;</p>
  <p><?php echo $row_GoodsInfoRecordset1['message_id']; ?>--<?php echo $row_GoodsInfoRecordset1['message_poster']; ?></p>
  <p><?php echo $row_GoodsInfoRecordset1['message_time']; ?></p>
  <p><?php echo $row_GoodsInfoRecordset1['message_title']; ?></p>
  <p><?php echo $row_GoodsInfoRecordset1['message_content']; ?></p>
  <p><?php echo $row_GoodsInfoRecordset1['message_reply']; ?></p>
  <p><hr></p>
  <?php } while ($row_GoodsInfoRecordset1 = mysql_fetch_assoc($GoodsInfoRecordset1)); ?><p><a href="<?php printf("%s?pageNum_GoodsInfoRecordset1=%d%s", $currentPage, 0, $queryString_GoodsInfoRecordset1); ?>">第一页</a> <a href="<?php printf("%s?pageNum_GoodsInfoRecordset1=%d%s", $currentPage, max(0, $pageNum_GoodsInfoRecordset1 - 1), $queryString_GoodsInfoRecordset1); ?>">上一页</a> <a href="<?php printf("%s?pageNum_GoodsInfoRecordset1=%d%s", $currentPage, min($totalPages_GoodsInfoRecordset1, $pageNum_GoodsInfoRecordset1 + 1), $queryString_GoodsInfoRecordset1); ?>">下一页</a> <a href="<?php printf("%s?pageNum_GoodsInfoRecordset1=%d%s", $currentPage, $totalPages_GoodsInfoRecordset1, $queryString_GoodsInfoRecordset1); ?>">最后页</a></p>
</body>
</html>
<?php
mysql_free_result($GoodsInfoRecordset1);
?>
